#include "widget.h"
#include "ui_widget.h"
#include <QRegExpValidator>
#include <QValidator>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QRegExp regExp("^1\\d{10}$");
    QValidator *validator = new QRegExpValidator(regExp, this);
    ui->lineEdit_number->setValidator(validator);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_lineEdit_number_textEdited(const QString &arg1)
{
    QString content = arg1; // 获取文本框内容
    int pos = 0;
    if(ui->lineEdit_number->validator()->validate(content, pos) == QValidator::Acceptable)
        ui->pushButton_verify->setEnabled(true);
    else
        ui->pushButton_verify->setEnabled(false);
}
